<template>
  <div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
      <el-form-item label="用户名" prop="UserName">
        <el-input v-model="formData.UserName" placeholder="请输入用户名" clearable :style="{width: '100%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="密码" prop="PassWord">
        <el-input v-model="formData.PassWord" placeholder="请输入密码" clearable show-password
          :style="{width: '100%'}"></el-input>
      </el-form-item>
      <el-form-item label="用户手机号" prop="UserTel">
        <el-input v-model="formData.UserTel" placeholder="请输入用户手机号" clearable :style="{width: '100%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="用户邮箱" prop="UserEmail">
        <el-input v-model="formData.UserEmail" placeholder="请输入用户邮箱" clearable :style="{width: '100%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="用户状态" prop="Enable" required>
        <el-switch v-model="formData.Enable"></el-switch>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  components: {},
  props: [],
  data () {
    return {
      formData: {
        UserName: undefined,
        PassWord: undefined,
        UserTel: undefined,
        UserEmail: undefined,
        Enable: false
      },
      rules: {
        UserName: [{
          required: true,
          message: '请输入用户名',
          trigger: 'blur'
        }],
        PassWord: [{
          required: true,
          message: '请输入密码',
          trigger: 'blur'
        }, {
          pattern: /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/,
          message: '密码不合符规范',
          trigger: 'blur'
        }],
        UserTel: [{
          required: true,
          message: '请输入用户手机号',
          trigger: 'blur'
        }, {
          pattern: /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/,
          message: '手机号码格式错误',
          trigger: 'blur'
        }],
        UserEmail: [{
          required: true,
          message: '请输入用户邮箱',
          trigger: 'blur'
        }, {
          pattern: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
          message: '邮箱格式不正确',
          trigger: 'blur'
        }]
      }
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    submitForm () {
      this.$refs['elForm'].validate(valid => {
        // if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm () {
      this.$refs['elForm'].resetFields()
    }
  }
}

</script>
<style>
</style>
